//
//  ViewController.m
//  2.18-1
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
//练习
//1.应用程序有哪些对象
//UIAlertView(3)
//UIActionSheet
//UILable(4)
//UIButton(1)
//UIView(1)
//ViewControler(1)
//UIApplication AppDelegate(1)
//UIWindow(1)
//
//
//
//
//
@interface ViewController ()<UIAlertViewDelegate,UIActionSheetDelegate>

@property (weak, nonatomic) IBOutlet UILabel *infoLable;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)btn1Pressed:(UIButton *)sender
{
    UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"判断" message:@"我长得帅吗" delegate:self cancelButtonTitle:@"帅的" otherButtonTitles:nil];
    
    [alertView show];
    
    
}
- (IBAction)btn2Pressed:(UIButton *)sender
{
    UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"判断" message:@"我长得帅吗" delegate:self cancelButtonTitle:@"帅的" otherButtonTitles:@"超帅",@"非常帅",nil];
    
    [alertView show];
    
    
}
- (IBAction)btn3Pressed:(UIButton *)sender
{
    UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"登录" message:@"请输入账号密码" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消",nil];
    alertView.alertViewStyle=UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];
    
    
}
- (IBAction)btn4Pressed:(UIButton *)sender
{
    UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"亚古兽进化" delegate:self cancelButtonTitle:@"丧尸暴龙兽" destructiveButtonTitle:@"战斗暴龙兽" otherButtonTitles:@"暴龙兽",@"机械暴龙兽",nil];
    [sheet showInView:self.view];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"点了第几个按钮=%i,按钮的文字是:%@",buttonIndex+1,[alertView buttonTitleAtIndex:buttonIndex]);
    NSLog(@"弹窗的信息是:%@",alertView.title);
    if([alertView.title isEqualToString:@"登录"])
    {
        NSString *info=[NSString stringWithFormat:@"账号:%@ 密码:%@",[alertView textFieldAtIndex:0].text,[alertView textFieldAtIndex:1].text];
        self.infoLable.text=info;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"操作表的标题:%@",actionSheet.title);
    NSLog(@"用户选择了哪一个按钮:%i,%@",buttonIndex,[actionSheet buttonTitleAtIndex:buttonIndex]);
    
    if(buttonIndex == actionSheet.destructiveButtonIndex)
    {
        NSLog(@"用户点了destructiveBtn");
         NSLog(@"进化成了%@",[actionSheet buttonTitleAtIndex:buttonIndex]);
    }
    else if(buttonIndex == actionSheet.cancelButtonIndex)
    {
        NSLog(@"用户点了cancelBtn");
        NSLog(@"进化成了%@",[actionSheet buttonTitleAtIndex:buttonIndex]);
    }
    else
    {
        NSLog(@"进化成了%@",[actionSheet buttonTitleAtIndex:buttonIndex]);
    }
}

@end
